/*表单验证*/
$().ready(function () {
        // 在键盘按下并释放及提交后验证提交表单
        $("#myform").validate({
          rules: {
            firstname: "required",
            lastname: "required",
            username: {
              required: true,
              isusername: true,
            },
            pwd: {
              required: true,
              ispwd: true,
            },
            repwd: {
              required: true,
              ispwd: true,
              equalTo: "#pwd",
            },
            gender: {
              required: true,
            },
            phone: {
              required: true,
              isPhone: true,
            },
            yzmo: {
                required:true
            },
             yzmt: {
                 required: true
             },
             spamn: {
                 required: true
             }
          },
          messages: {
            firstname: "请输入您的名字",
            lastname: "请输入您的姓氏",
            username: {
              required: "请输入用户名",
            },
            pwd: {
              required: "请输入密码",
            },
            repwd: {
              required: "请输入密码",
              equalTo: "两次密码输入不一致",
            },
            gender: {
              required: "必选一个",
            },
            phone: {
              required: "请输入联系方式",
            },
            yzmo: {
                required: "请输入验证码",
            },
            yzmt: {
                 required: "请输入手机验证码",
             },
             spamn: {
                 required: "请阅读并勾选",
             }
          },
        });
        // 用户名验证
        jQuery.validator.addMethod(
          "isusername",
          function (value, element) {
            var tel = /^[A-Za-z0-9_-]{6,12}$/;
            return this.optional(element) || tel.test(value);
          },
          "阿巴正确填写用户名"
        );
        // 密码验证
        jQuery.validator.addMethod(
          "ispwd",
          function (value, element) {
            var tel = /^[A-Za-z0-9_-]{8,16}$/;
            return this.optional(element) || tel.test(value);
          },
          "阿巴正确填写密码"
        );
        // 电话验证
        jQuery.validator.addMethod(
          "isPhone",
          function (value, element) {
            var tel = /^(13[0-9]|14[5|7]|15[0|1|2|3|5|6|7|8|9]|18[0|1|2|3|5|6|7|8|9])\d{8}$/;
            return this.optional(element) || tel.test(value);
          },
          "请输入正确的联系方式"
        );
      });